class DigitalHumanConfig:
    """数字人模型配置管理"""

    def __init__(self):
        self.configs = {
            "sadtalker": {
                "api_key": os.getenv("SADTALKER_API_KEY"),
                "base_url": "https://api.sadtalker.com/v1",
                "default_voice": "alloy",
                "default_style": "neutral"
            },
            "heygen": {
                "api_key": os.getenv("HEYGEN_API_KEY"),
                "base_url": "https://api.heygen.com/v1",
                "available_avatars": ["male1", "female1", "custom"],
                "video_quality": "high"
            },
            "synthesia": {
                "api_key": os.getenv("SYNTHESIA_API_KEY"),
                "base_url": "https://api.synthesia.io/v2",
                "avatars": ["anna", "michael", "liam"],
                "languages": ["en", "zh", "es", "fr"]
            },
            "d_id": {
                "api_key": os.getenv("D_ID_API_KEY"),
                "base_url": "https://api.d-id.com",
                "credits_balance": 0
            }
        }

        # 数字人模型参数默认值
        self.default_params = {
            "video_resolution": "1920x1080",
            "fps": 25,
            "background_color": "#FFFFFF",
            "voice_speed": 1.0,
            "voice_pitch": 1.0,
            "emotion_level": 0.7,
            "head_movement": "natural",
            "gesture_frequency": "medium"
        }

    def get_avatar_list(self, provider: str) -> List[Dict]:
        """获取可用的数字人avatar列表"""
        if provider == "heygen":
            return [
                {"id": "male1", "name": "男性形象1", "language": "zh"},
                {"id": "female1", "name": "女性形象1", "language": "zh"},
                {"id": "male2", "name": "男性形象2", "language": "en"}
            ]
        elif provider == "synthesia":
            return [
                {"id": "anna", "name": "Anna", "language": "en"},
                {"id": "michael", "name": "Michael", "language": "en"},
                {"id": "liam", "name": "Liam", "language": "en"}
            ]
        return []

    def validate_config(self, provider: str) -> bool:
        """验证配置是否完整"""
        config = self.configs.get(provider, {})
        return bool(config.get("api_key")) and bool(config.get("base_url"))